package tr.edu.metu.is.mega.server.timer;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

import tr.edu.metu.is.mega.server.business.MailService;
import tr.edu.metu.is.mega.server.dao.ActivityDAO;
import tr.edu.metu.is.mega.server.entity.Activity;

/**
 * Sends notification e-mail to students for activities needs to be alerted,
 * non-submitted activity notifiers for reviewers.
 */
public class ActivityNotifier {

    public static void doJob() {
        System.out.println("ActivityNotifier.doJob() "+ new Date());

        ActivityDAO dao = new ActivityDAO();
        List<Activity> findByNamedNativeQuery = dao.findByNamedNativeQuery("Activity.alertActivities", new HashMap<Integer, Object>());
        for (Activity activity : findByNamedNativeQuery) {
            MailService.activityMailer(activity);
        }
    }
}
